<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<c:set var="ctxPath" value="${pageContext.request.contextPath}"/>
<!DOCTYPE html>
<style>
    body {
        background: #E5E5E5;
    }

    [type='text'] {
        font-size: 18px;
        background: #F3F3F3;
        margin-top: 10px;
        border: 1px solid #666;
        height: 35px;
    }

    [type='button'] {
        font-size: 18px;
        margin-top: 10px;
        height: 38px;
        width: 100px;
    }

    [type='button']:hover {
        background: #D5D5D5;
        cursor: pointer;
        border: 1px solid #666;
    }

    select {
        font-size: 16px;
        margin-top: 10px;
        height: 32px;
        width: 180px;
        background: #E3E3E3;
    }

    textarea {
        background: #F3F3F3;
        margin-top: 10px;
        font-size: 17px;
    }
</style>
<script src="${ctxPath}/static/js/jquery-1.11.1.min.js"></script>
<script>
    function submitLeave() {
        $.ajax(
            {
                url: '${ctxPath}/reimbursement/submitReimbursement',
                type: 'post',
                data: {
                    initiator: $('#initiator').val(),
                    money: $('#money').val(),
                    reason: $('#reason').val()
                },
                dataType: "json",
                success: function (json) {
                    console.log(json);
                    var ret = json['result'];
                    var cause = json['cause'];
                    if (ret = 'success') {
                        alert('申请报销成功。');
                        //{ps}查看我发起的任务。
                        window.location = "${ctxPath}/reimbursement/myInitiate";
                    } else {
                        alert('申请报销失败, 原因:' + cause);
                    }
                }
            }
        );
    }
</script>

<div style="margin-left:20px;">
    <div style="font-size:25px;font-weight:bold;">我要报销</div>
    <form id="frmLeave">
        <!--  发起人ID:initiator -->
        <input id="initiator" type="hidden" value="${user.id}"/><br/>

        <label>报销金额:</label>
        <label for="money"></label><textarea id="money" cols="35" rows="5">
	</textarea>
        <br/>

        <label>报销原因:</label>
        <label for="reason"></label><textarea id="reason" cols="35" rows="5">
	</textarea>
        <br/>
        <input type="button" value="提交报销"
               onclick="submitLeave();"/><br/><br/>
    </form>
</div>